package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dao.UsersMapper;
import com.tencent.wxcloudrun.model.Users;
import com.tencent.wxcloudrun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lichongbing
 * @version 1.0.0
 * @createdate 2023/2/18 07:54
 * @description: TODO
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UsersMapper mapper;

    @Override
    public String getAvatarUrl(String openid) {
        String avatarurl = mapper.selectByopenid(openid).getAvatarurl();
        return avatarurl;
    }

    @Override
    public boolean issign(String openid) {
        Users users = mapper.selectByopenid(openid);
        if (users == null) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean insert(Users users) {
       int addOption = mapper.addOption(users.getOpenid());
        int insert = mapper.insert(users);
        if (insert ==1 && addOption== 1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Users getByOpenid(String openid) {

        return mapper.getByOpenid(openid);
    }

    @Override
    public int updatenickname(String nickname, String openid, String birthday) {
        int updatenickname = mapper.updatenickname(nickname, openid,birthday);
        return updatenickname;
    }



    @Override
    public int updateAvatarUrl(String nickname, String openid) {
        int updateAvatarUrl = mapper.updateAvatarUrl(nickname, openid);
        return updateAvatarUrl;
    }

    @Override
    public int updateuserphone(String phoneNumber, String openid) {
        int updateAvatarUrl = mapper.updateuserphone(phoneNumber, openid);
        return updateAvatarUrl;
    }
}
